home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / MacFormat 92 CD / Shareware Plus / Utilities / FolderSynchronizer 1.8.9 / FoldersSynchronizer / FoldersSynchronizer.9 / AllScripts_5_MultipliFolders.ls < prev    next >
Encoding:
Text File  |  2000-05-10  |  16.8 KB  |  500 lines

  1. on Multipli___________________________
  2. end
  3.  
  4. on InitMulti
  5.   global gMultiAll, gMaxMulti, gCurrMulti, gRowsMulti, glineHeightMulti, gTempMultiOnList, gMultiOnList, gTempMultiPathSourceList, gMultiPathSourceList, gTempMultiPathDestList, gMultiPathDestList, gRememberMultiList
  6.   set gMultiAll to 0
  7.   set gRememberMultiList to 0
  8.   set gMaxMulti to 7
  9.   set gCurrMulti to 1
  10.   set gRowsMulti to 7
  11.   set gTempMultiOnList to []
  12.   set gMultiOnList to []
  13.   set gTempMultiPathSourceList to []
  14.   set gMultiPathSourceList to []
  15.   set gTempMultiPathDestList to []
  16.   set gMultiPathDestList to []
  17.   repeat with i = 1 to gMaxMulti
  18.     append(gTempMultiOnList, 1)
  19.     append(gMultiOnList, 1)
  20.     append(gTempMultiPathSourceList, 0)
  21.     append(gMultiPathSourceList, 0)
  22.     append(gTempMultiPathDestList, 0)
  23.     append(gMultiPathDestList, 0)
  24.   end repeat
  25.   set glineHeightMulti to 18
  26.   set the textHeight of member "fOnOffMulti" to glineHeightMulti
  27.   set the textHeight of member "fSourceList" to glineHeightMulti
  28.   set the textHeight of member "fDestList" to glineHeightMulti
  29.   set the scrollTop of member "fOnOffMulti" to 0
  30.   set the scrollTop of member "fSourceList" to 0
  31.   set the scrollTop of member "fDestList" to 0
  32. end
  33.  
  34. on GoMulti
  35.   global gTempMultiAll, gMultiAll, gTempMultiOnList, gMultiOnList, gTempMultiPathSourceList, gMultiPathSourceList, gTempMultiPathDestList, gMultiPathDestList, gMaxMulti, gGrigio, gNero, gSep
  36.   if voidp(gMultiAll) then
  37.     set gMultiAll to 0
  38.   end if
  39.   set gTempMultiAll to gMultiAll
  40.   put EMPTY into field "fSourceList"
  41.   put EMPTY into field "fDestList"
  42.   set the foreColor of field "fOnOffMulti" to gNero
  43.   set the foreColor of field "fSourceList" to gNero
  44.   set the foreColor of field "fDestList" to gNero
  45.   set tempSources to EMPTY
  46.   set tempDests to EMPTY
  47.   set gTempMultiOnList to value(string(gMultiOnList))
  48.   set gTempMultiPathSourceList to value(string(gMultiPathSourceList))
  49.   set gTempMultiPathDestList to value(string(gMultiPathDestList))
  50.   set oldDelimiter to the itemDelimiter
  51.   set the itemDelimiter to gSep
  52.   repeat with i = 1 to gMaxMulti
  53.     set myItem to getAt(gTempMultiPathSourceList, i)
  54.     if myItem = 0 then
  55.       set myItem to " "
  56.     else
  57.       set myItem to the last item in myItem
  58.     end if
  59.     put myItem & RETURN after tempSources
  60.     set myItem to getAt(gTempMultiPathDestList, i)
  61.     if myItem = 0 then
  62.       set myItem to " "
  63.     else
  64.       set myItem to the last item in myItem
  65.     end if
  66.     put myItem & RETURN after tempDests
  67.   end repeat
  68.   set the itemDelimiter to oldDelimiter
  69.   delete char -30000 of tempSources
  70.   delete char -30000 of tempDests
  71.   put tempSources into field "fSourceList"
  72.   put tempDests into field "fDestList"
  73.   repeat with i = 1 to gMaxMulti
  74.     if not getAt(gTempMultiOnList, i) then
  75.       set the foreColor of line i of field "fOnOffMulti" to gGrigio
  76.       set the foreColor of line i of field "fSourceList" to gGrigio
  77.       set the foreColor of line i of field "fDestList" to gGrigio
  78.     end if
  79.   end repeat
  80.   go("Multi")
  81.   SetMenuCredits()
  82. end
  83.  
  84. on SetOneMultipleOnOff myLinea
  85.   global gTempMultiOnList, gGrigio, gNero
  86.   set a to the foreColor of char 1 of line myLinea of field "fOnOffMulti" = gNero
  87.   set a to not a
  88.   if a then
  89.     set colore to gNero
  90.     set myValore to 1
  91.   else
  92.     set colore to gGrigio
  93.     set myValore to 0
  94.   end if
  95.   set the foreColor of char 1 of line myLinea of field "fOnOffMulti" to colore
  96.   set the foreColor of line myLinea of field "fSourceList" to colore
  97.   set the foreColor of line myLinea of field "fDestList" to colore
  98.   setAt(gTempMultiOnList, myLinea, myValore)
  99. end
  100.  
  101. on AskForOneMultipleSource myLinea
  102.   global gTempMultiPathSourceList, gTempMultiPathDestList, gSep, gMultiPathSourceList
  103.   if the optionDown then
  104.     put " " into line myLinea of field "fSourceList"
  105.     setAt(gTempMultiPathSourceList, myLinea, 0)
  106.   else
  107.     set theFolder to getAt(gTempMultiPathSourceList, myLinea)
  108.     if theFolder <> 0 then
  109.       if OSIsDirectory(theFolder & gSep) = 1 then
  110.         dosSetCurrentFolder(ExtractParentFolder(theFolder))
  111.       end if
  112.     end if
  113.     set myFolder to OSSelectFolder()
  114.     if myFolder <> 0 then
  115.       set myTempDest to getAt(gTempMultiPathDestList, myLinea)
  116.       if (stringp(myTempDest) = 1) and (myFolder = (myTempDest & gSep)) then
  117.         AlertBox("You cannot choose the same Folder two times.")
  118.         exit
  119.       end if
  120.       put ExtractFileNameFromPath(myFolder) into line myLinea of field "fSourceList"
  121.       delete char -30000 of myFolder
  122.       setAt(gTempMultiPathSourceList, myLinea, myFolder)
  123.     end if
  124.   end if
  125. end
  126.  
  127. on AskForOneMultipleDest myLinea
  128.   global gTempMultiPathSourceList, gTempMultiPathDestList, gSep
  129.   if the optionDown then
  130.     put " " into line myLinea of field "fDestList"
  131.     setAt(gTempMultiPathDestList, myLinea, 0)
  132.   else
  133.     set theFolder to getAt(gTempMultiPathDestList, myLinea)
  134.     if theFolder <> 0 then
  135.       if OSIsDirectory(theFolder & gSep) = 1 then
  136.         dosSetCurrentFolder(ExtractParentFolder(theFolder))
  137.       end if
  138.     end if
  139.     set myFolder to OSSelectFolder()
  140.     if myFolder <> 0 then
  141.       set myTempSource to getAt(gTempMultiPathSourceList, myLinea)
  142.       if (stringp(myTempSource) = 1) and (myFolder = (myTempSource & gSep)) then
  143.         AlertBox("You cannot choose the same Folder two times.")
  144.         exit
  145.       end if
  146.       put ExtractFileNameFromPath(myFolder) into line myLinea of field "fDestList"
  147.       delete char -30000 of myFolder
  148.       setAt(gTempMultiPathDestList, myLinea, myFolder)
  149.     end if
  150.   end if
  151. end
  152.  
  153. on DoPopChain myMember, riga
  154.   global gSep, gTempMultiPathSourceList, gTempMultiPathDestList, gMyStageWidth, gMyStageHeight
  155.   if myMember = "fSourceList" then
  156.     set mySprite to 23
  157.     set myPath to getAt(gTempMultiPathSourceList, riga)
  158.   else
  159.     set mySprite to 24
  160.     set myPath to getAt(gTempMultiPathDestList, riga)
  161.   end if
  162.   if line riga of field myMember = " " then
  163.     exit
  164.   end if
  165.   set oldDelimiter to the itemDelimiter
  166.   set the itemDelimiter to gSep
  167.   set numItem to the number of items in myPath
  168.   set myChain to EMPTY
  169.   repeat with i = 0 to numItem - 1
  170.     set k to numItem - i
  171.     put item k of myPath & RETURN after myChain
  172.   end repeat
  173.   delete char -30000 of myChain
  174.   set the itemDelimiter to oldDelimiter
  175.   put myChain into field "fPopChain"
  176.   set myH to the left of sprite mySprite - 1
  177.   set myV to ((riga - 1) * 18) - 1 + the top of sprite mySprite
  178.   if (myV + the height of member "fPopChain" + 4) > gMyStageHeight then
  179.     set myV to gMyStageHeight - the height of member "fPopChain" - 4
  180.   end if
  181.   set the loc of sprite 58 to point(myH, myV)
  182.   updateStage()
  183.   repeat while the stillDown
  184.   end repeat
  185.   set the loc of sprite 58 to point(1000, 1000)
  186.   updateStage()
  187.   put " " into field "fPopChain"
  188. end
  189.  
  190. on ApplyMulti
  191.   global gTempMultiAll, gTempMultiOnList, gTempMultiPathSourceList, gTempMultiPathDestList
  192.   set err to ImpostaMultiList(gTempMultiAll, gTempMultiOnList, gTempMultiPathSourceList, gTempMultiPathDestList)
  193.   if err then
  194.     exit
  195.   end if
  196.   if not gTempMultiAll then
  197.     ImpostaNoMultiXLists()
  198.   end if
  199.   CheckSyncButton()
  200.   GoLista()
  201. end
  202.  
  203. on ImpostaMultiList xTempMultiAll, xTempMultiOnList, xTempMultiPathSourceList, xTempMultiPathDestList
  204.   global gMultiAll, gMultiOnList, gMultiPathSourceList, gMultiPathDestList, gMultiXSource, gMultiXDest, gSourceFolder, gDestFolder, gMaxMulti, gSep
  205.   set xMultiXSource to []
  206.   set xMultiXDest to []
  207.   set k to 0
  208.   repeat with i = 1 to gMaxMulti
  209.     if getAt(xTempMultiOnList, i) then
  210.       set iSource to getAt(xTempMultiPathSourceList, i)
  211.       set iDest to getAt(xTempMultiPathDestList, i)
  212.       set SourceDefin to stringp(iSource) = 1
  213.       set DestDefin to stringp(iDest) = 1
  214.       if SourceDefin and not DestDefin and xTempMultiAll then
  215.         if the frameLabel = "Multi" then
  216.           AlertBox("Cannot set an empty destination folder in line" && i & ".")
  217.         end if
  218.         return 1
  219.         next repeat
  220.       end if
  221.       if not SourceDefin and DestDefin and xTempMultiAll then
  222.         if the frameLabel = "Multi" then
  223.           AlertBox("Cannot set an empty source folder in line" && i & ".")
  224.         end if
  225.         return 1
  226.         next repeat
  227.       end if
  228.       if SourceDefin and DestDefin and xTempMultiAll then
  229.         set iSource to iSource & gSep
  230.         set iDest to iDest & gSep
  231.         if OSIsDirectory(iSource) <> 1 then
  232.           if the frameLabel = "Multi" then
  233.             AlertBox("Source Folder in line" && i && "not found.")
  234.           end if
  235.           return 1
  236.         else
  237.           if OSIsDirectory(iDest) <> 1 then
  238.             if the frameLabel = "Multi" then
  239.               AlertBox("Destination Folder in line" && i && "not found.")
  240.             end if
  241.             return 1
  242.           end if
  243.         end if
  244.         set k to k + 1
  245.         append(xMultiXSource, iSource)
  246.         append(xMultiXDest, iDest)
  247.       end if
  248.     end if
  249.   end repeat
  250.   if (k = 0) and xTempMultiAll then
  251.     if the frameLabel = "Multi" then
  252.       AlertBox("Cannot set an empty list on.")
  253.     end if
  254.     return 1
  255.   end if
  256.   if the frameLabel = "Multi" then
  257.     set gMultiAll to xTempMultiAll
  258.     set gMultiOnList to value(string(xTempMultiOnList))
  259.     set gMultiPathSourceList to value(string(xTempMultiPathSourceList))
  260.     set gMultiPathDestList to value(string(xTempMultiPathDestList))
  261.   end if
  262.   if xTempMultiAll then
  263.     set gMultiXSource to value(string(xMultiXSource))
  264.     set gMultiXDest to value(string(xMultiXDest))
  265.     set gSourceFolder to getAt(gMultiXSource, 1)
  266.     set gDestFolder to getAt(gMultiXDest, 1)
  267.     put "Multiple Top Folders:" && string(k) into field "fSourceFolder"
  268.     put "Multiple Bottom Folders:" && string(k) into field "fDestFolder"
  269.     put " " into field "fItems"
  270.   end if
  271.   return 0
  272. end
  273.  
  274. on ImpostaNoMultiXLists
  275.   global gSourceFolder, gDestFolder, gTopFolder, gBottomFolder
  276.   set gSourceFolder to gTopFolder
  277.   set gDestFolder to gBottomFolder
  278.   put AccorciaNome(gSourceFolder) into field "fSourceFolder"
  279.   put AccorciaNome(gDestFolder) into field "fDestFolder"
  280.   put " " into field "fItems"
  281. end
  282.  
  283. on ImpostagSourceDestFolders
  284.   global gMultiAll, gRememberMultiList, gMultiOnList, gMultiPathSourceList, gMultiPathDestList
  285.   if gRememberMultiList then
  286.     set err to ImpostaMultiList(gMultiAll, gMultiOnList, gMultiPathSourceList, gMultiPathDestList)
  287.     if err then
  288.       set gMultiAll to 0
  289.       ImpostaNoMultiXLists()
  290.     end if
  291.   end if
  292.   if not gMultiAll then
  293.     ImpostaNoMultiXLists()
  294.   end if
  295. end
  296.  
  297. on DoMultiSynchronize
  298.   global gMultiXSource, gMultiXDest, gIterMulti, gSourceFolder, gDestFolder, gTimerAll, gStopTimerAll
  299.   GoLista()
  300.   PreSynchronizing()
  301.   set numCicliMulti to count(gMultiXSource)
  302.   repeat with gIterMulti = 1 to numCicliMulti
  303.     set gSourceFolder to getAt(gMultiXSource, gIterMulti)
  304.     set gDestFolder to getAt(gMultiXDest, gIterMulti)
  305.     put AccorciaNome(gSourceFolder) into field "fSourceFolder"
  306.     put AccorciaNome(gDestFolder) into field "fDestFolder"
  307.     DoOneSynchronize(gIterMulti)
  308.   end repeat
  309.   FineMultiSync()
  310. end
  311.  
  312. on FineMultiSync
  313.   global gOneDirection, gBeepWhenDone, gIterMulti, gTimerAll, gStopTimerAll, gLastBackUpDate
  314.   put " " into field "fItems"
  315.   if gOneDirection then
  316.     set myButton to "BackUp"
  317.     if (gIterMulti - 1) > 1 then
  318.       set myOperation to "BackUps"
  319.     else
  320.       set myOperation to "BackUp"
  321.     end if
  322.   else
  323.     set myButton to "Synchronize"
  324.     if (gIterMulti - 1) > 1 then
  325.       set myOperation to "Synchronizations"
  326.     else
  327.       set myOperation to "Synchronization"
  328.     end if
  329.   end if
  330.   put MyOperationBtn() into field "P4"
  331.   put "‚Ä¢" && string(gIterMulti - 1) && "Multiple" && myOperation && "done." into field "fItems"
  332.   FrecciaShortLog(1)
  333.   put "Multiple Top Folders Done:" && string(gIterMulti - 1) into field "fSourceFolder"
  334.   put "Multiple Bottom Folders Done:" && string(gIterMulti - 1) into field "fDestFolder"
  335.   set gLastBackUpDate to [TodayYear(1), TodayMonth(1), TodayDay(1)]
  336.   cursor(-1)
  337.   set gTimerAll to gStopTimerAll
  338.   beep(gBeepWhenDone)
  339. end
  340.  
  341. on TastoMulti
  342.   global gBianco, gNero
  343.   if (the key = RETURN) or (charToNum(the key) = 3) then
  344.     set mySprite to 39
  345.   else
  346.     if the keyCode = 53 then
  347.       set mySprite to 36
  348.     else
  349.       exit
  350.     end if
  351.   end if
  352.   set myBtnUp to the name of member the member of sprite mySprite
  353.   set myTextMember to the member of sprite (mySprite + 1)
  354.   set the member of sprite mySprite to BtnDw(myBtnUp)
  355.   set the forecolor of myTextMember to gBianco
  356.   updateStage()
  357.   repeat with i = 0 to 15000
  358.   end repeat
  359.   set the member of sprite mySprite to myBtnUp
  360.   set the foreColor of member myTextMember to gNero
  361.   updateStage()
  362.   if mySprite = 39 then
  363.     ApplyMulti()
  364.   else
  365.     if mySprite = 36 then
  366.       GoLista()
  367.     end if
  368.   end if
  369. end
  370.  
  371. on AskDeleteAllMulti
  372.   DialogBoxSiNo("Would you delete the multiple list?", "DeleteAllMulti", "nothing")
  373. end
  374.  
  375. on DeleteAllMulti
  376.   global gTempMultiOnList, gTempMultiPathSourceList, gTempMultiPathDestList, gMaxMulti, gNero
  377.   updateStage()
  378.   set stringa to " " & RETURN & " " & RETURN & " " & RETURN & " " & RETURN & " " & RETURN & " " & RETURN & " "
  379.   put stringa into field "fSourceList"
  380.   put stringa into field "fDestList"
  381.   set the foreColor of field "fOnOffMulti" to gNero
  382.   set the foreColor of field "fSourceList" to gNero
  383.   set the foreColor of field "fDestList" to gNero
  384.   repeat with i = 1 to gMaxMulti
  385.     setAt(gTempMultiOnList, i, 1)
  386.     setAt(gTempMultiPathSourceList, i, 0)
  387.     setAt(gTempMultiPathDestList, i, 0)
  388.   end repeat
  389. end
  390.  
  391. on SaveListaMulti
  392.   global gTempMultiOnList, gTempMultiPathSourceList, gTempMultiPathDestList
  393.   set myFile to DisplaySaveMyFile("MultipleList")
  394.   if myFile = EMPTY then
  395.     exit
  396.   end if
  397.   if OSIsDirectory(myFile) = 0 then
  398.     set err to OSDelete(myFile)
  399.     if err then
  400.       case err of
  401.         (-47):
  402.           set why to " because it's opened by another application."
  403.         (-45):
  404.           set why to " because it's locked."
  405.         (-44):
  406.           set why to " because the disk is locked."
  407.         otherwise:
  408.           set why to "."
  409.       end case
  410.       put "err" & err
  411.       AlertBox("Cannot replace the file" && QUOTE & ExtractFileNameFromPath(myFile) & QUOTE & why)
  412.       exit
  413.     end if
  414.   end if
  415.   set mystringa to "global gTempMultiOnList, gTempMultiPathSourceList, gTempMultiPathDestList" & RETURN & RETURN & "set gTempMultiOnList=" & gTempMultiOnList & RETURN & "set gTempMultiPathSourceList=value(" & SostApici(string(gTempMultiPathSourceList)) & ")" & RETURN & "set gTempMultiPathDestList=value(" & SostApici(string(gTempMultiPathDestList)) & ")" & RETURN
  416.   SaveTextFile(myFile, mystringa, "List", "FLSY")
  417. end
  418.  
  419. on LoadListaMulti
  420.   global gTempMultiOnList, gTempMultiPathSourceList, gTempMultiPathDestList
  421.   set myFile to OSSelectFile(["List", "FLSY"])
  422.   if myFile = 0 then
  423.     exit
  424.   end if
  425.   if GetCreator(myFile) <> "FLSY" then
  426.     AlertBox("This is not a FoldersSycnhonizer file.")
  427.     exit
  428.   end if
  429.   set myscript to OpenMyFile(myFile)
  430.   if myscript = 0 then
  431.     AlertBox("Cannot read this file.")
  432.   else
  433.     do(myscript)
  434.     SeLoadListaMulti()
  435.   end if
  436. end
  437.  
  438. on SeLoadListaMulti
  439.   global gTempMultiAll, gMultiAll, gTempMultiOnList, gMultiOnList, gTempMultiPathSourceList, gMultiPathSourceList, gTempMultiPathDestList, gMultiPathDestList, gMaxMulti, gGrigio, gNero, gSep
  440.   set pos22 to the loc of sprite 22
  441.   set pos23 to the loc of sprite 23
  442.   set pos24 to the loc of sprite 24
  443.   set the loc of sprite 22 to point(-10000, -10000)
  444.   set the loc of sprite 23 to point(-10000, -10000)
  445.   set the loc of sprite 24 to point(-10000, -10000)
  446.   updateStage()
  447.   put EMPTY into field "fSourceList"
  448.   put EMPTY into field "fDestList"
  449.   set the foreColor of field "fOnOffMulti" to gNero
  450.   set the foreColor of field "fSourceList" to gNero
  451.   set the foreColor of field "fDestList" to gNero
  452.   set tempSources to EMPTY
  453.   set tempDests to EMPTY
  454.   set oldDelimiter to the itemDelimiter
  455.   set the itemDelimiter to gSep
  456.   repeat with i = 1 to gMaxMulti
  457.     set myItem to getAt(gTempMultiPathSourceList, i)
  458.     if myItem = 0 then
  459.       set myItem to " "
  460.     else
  461.       set myItem to the last item in myItem
  462.     end if
  463.     put myItem & RETURN after tempSources
  464.     set myItem to getAt(gTempMultiPathDestList, i)
  465.     if myItem = 0 then
  466.       set myItem to " "
  467.     else
  468.       set myItem to the last item in myItem
  469.     end if
  470.     put myItem & RETURN after tempDests
  471.   end repeat
  472.   set the itemDelimiter to oldDelimiter
  473.   delete char -30000 of tempSources
  474.   delete char -30000 of tempDests
  475.   put tempSources into field "fSourceList"
  476.   put tempDests into field "fDestList"
  477.   repeat with i = 1 to gMaxMulti
  478.     if not getAt(gTempMultiOnList, i) then
  479.       set the foreColor of line i of field "fOnOffMulti" to gGrigio
  480.       set the foreColor of line i of field "fSourceList" to gGrigio
  481.       set the foreColor of line i of field "fDestList" to gGrigio
  482.     end if
  483.   end repeat
  484.   set the loc of sprite 22 to pos22
  485.   set the loc of sprite 23 to pos23
  486.   set the loc of sprite 24 to pos24
  487.   updateStage()
  488. end
  489.  
  490. on SetIngrigisceMulti
  491.   global gTempMultiAll
  492.   if not value(gTempMultiAll) then
  493.     set myPoint to point(the left of sprite 17 + 1, the top of sprite 17 + 1)
  494.     set the loc of sprite 100 to myPoint
  495.   else
  496.     set the loc of sprite 100 to point(10000, 10000)
  497.   end if
  498.   updateStage()
  499. end
  500.